home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / SAMPLES1.PAK / LINEITEM.MNU < prev    next >
Text File  |  1995-07-18  |  7KB  |  198 lines

  1. ******************************************************************************
  2. *  PROGRAM:      Lineitem.mnu
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         12/93
  7. *
  8. *  UPDATED:      6/95
  9. *
  10. *  REVISION:     $Revision:   1.12  $
  11. *
  12. *  VERSION:      Visual dBASE
  13. *
  14. *  DESCRIPTION:  This is a menu file used by Custord.wfm for
  15. *                performing line item tasks.  It allows adding and deleting
  16. *                records, searching for a value in the stock_no field of the
  17. *                current table viewed, and exiting the form in view.
  18. *
  19. *  PARAMETERS:   FormObj -- the form to which this menu will belong.
  20. *
  21. *  CALLS:        None
  22. *
  23. *  USAGE:        form.menuFile = "Lineitem.mnu"
  24. *
  25. *******************************************************************************
  26. #include <Messdlg.h>
  27.  
  28. ** END HEADER -- do not remove this line*
  29. * Generated on 05/06/94
  30. *
  31. Parameter FormObj
  32. NEW LINEITEMMENU(FormObj,"Root")
  33. CLASS LINEITEMMENU(FormObj,Name) OF MENUBAR(FormObj,Name)
  34.    this.Text = ""
  35.    this.OnInit = {;set procedure to &_dbwinhome.samples\Sampproc.prg}
  36.  
  37.    DEFINE MENU FILE OF THIS;
  38.        PROPERTY;
  39.          Text "&File"
  40.  
  41.          DEFINE MENU EXIT OF THIS.FILE;
  42.              PROPERTY;
  43.                OnClick CLASS::EXIT_ONCLICK,;
  44.                Text "E&xit",;
  45.                StatusMessage "Leave form."
  46.  
  47.    DEFINE MENU LINEITEM OF THIS;
  48.        PROPERTY;
  49.          Text "&Lineitem"
  50.  
  51.          DEFINE MENU VIEWEDIT OF THIS.LINEITEM;
  52.              PROPERTY;
  53.                OnClick CLASS::VIEWEDITONCLICK,;
  54.                Text "&Edit",;
  55.                Shortcut "Ctrl-E",;
  56.                StatusMessage "Edit data."
  57.  
  58.          DEFINE MENU SEPARATOR1 OF THIS.LINEITEM;
  59.              PROPERTY;
  60.                Separator .T.,;
  61.                Text ""
  62.  
  63.          DEFINE MENU ADD OF THIS.LINEITEM;
  64.              PROPERTY;
  65.                OnClick CLASS::ADDONCLICK,;
  66.                Text "&Add",;
  67.                Enabled .T.,;
  68.                Shortcut "Ctrl-A",;
  69.                StatusMessage "Add a new line item."
  70.  
  71.          DEFINE MENU DELETE OF THIS.LINEITEM;
  72.              PROPERTY;
  73.                OnClick CLASS::DELETEONCLICK,;
  74.                Text "&Delete",;
  75.                Enabled .F.,;
  76.                Shortcut "Ctrl-D",;
  77.                StatusMessage "Delete the current line item."
  78.  
  79.          DEFINE MENU SEPARATOR2 OF THIS.LINEITEM;
  80.              PROPERTY;
  81.                Separator .T.,;
  82.                Text ""
  83.  
  84.          DEFINE MENU SEARCH OF THIS.LINEITEM;
  85.              PROPERTY;
  86.                OnClick CLASS::SEARCHONCLICK,;
  87.                Text "&Search ...",;
  88.                Shortcut "Ctrl-S",;
  89.                StatusMessage "Search for a line item."
  90.  
  91.  
  92.  
  93.    ****************************************************************************
  94.    procedure SearchOnClick
  95.  
  96.    * Bring up Search.wfm.
  97.    ****************************************************************************
  98.    private searchForm, searchItem, saveRec, saveFilt, keyFieldName
  99.  
  100.    if reccount() = 0                        && If table is empty, don't search
  101.       InformationMessage("This table is empty.", "Oops")
  102.    else
  103.       form.CheckChanged(.t.)
  104.       set procedure to &_dbwinhome.samples\Search.wfm additive
  105.       searchForm = new SearchForm()
  106.       searchForm.keyName = "Stock Number"   && Indicator of key expression
  107.       searchForm.formatting = "99999"       && format specific to this key
  108.       searchForm.mdi = .F.
  109.       searchItem = searchForm.Readmodal()
  110.       if type("searchItem") = "O" .and. searchItem.id <> 0
  111.                                       && If search wasn't cancelled
  112.          saveRec = recno()            && save current record in case seek is unsucessfull
  113.  
  114.          keyFieldName = "Stock_no"
  115.          * Change value to '0' padded string of length 5
  116.          locate for &keyFieldName = searchForm.value
  117.          if .not. found()
  118.             InformationMessage(FormatStr("Stock Number %1 \n Was not Found.",;
  119.                                          searchForm.value),;
  120.                                "Info")
  121.             if saveRec <= reccount()    && If weren't at eof(), go to saveRec
  122.                go saveRec
  123.             else
  124.                go bottom
  125.             endif
  126.          endif
  127.       endif
  128.  
  129.       searchForm.Release()
  130.       close procedure &_dbwinhome.samples\Search.wfm
  131.    endif
  132.  
  133.  
  134.    ****************************************************************************
  135.    procedure DeleteOnClick
  136.  
  137.    * Delete current record.
  138.    ****************************************************************************
  139.  
  140.    if ConfirmationMessage("Are you sure you want to delete this line item?",;
  141.                           "Confirm") = YES
  142.       delete  && DELETED is ON, so deleted records are still there until
  143.               && a PACK is executed
  144.       commit()
  145.       form.curPage.changesMade = .F.
  146.       begintrans()
  147.      *form.custOrdNextButton.OnClick()  && Move to next record
  148.    endif
  149.  
  150.  
  151.    ****************************************************************************
  152.    procedure AddOnClick
  153.  
  154.    * Add new record.
  155.    ****************************************************************************
  156.    private addForm, curStockNo, stockNoField, newStockNo
  157.  
  158.    form.CheckChanged(.t.)
  159.    if ConfirmationMessage("Are you sure you want to add a line item?",;
  160.                           "Confirmation") = YES
  161.  
  162.  
  163.       if .not. form.curPage.inEditMode
  164.          form.ViewEdit()                      && Make sure record is editable
  165.       endif
  166.       form.curPage.changesMade = .T.
  167.       form.previousRecord = recno()
  168.  
  169.       stockNoField = field(2)        && Stock_no field
  170.       curStockNo = &stockNoField     && Current order number
  171.       newStockNo = str(val(form.maxStockNo) + 1, 5)
  172.       append blank
  173.       * replace &orderNoField with curOrderNo   && Integrity takes care of this
  174.       replace &stockNoField with newStockNo
  175.       form.maxStockNo = newStockNo
  176.       refresh
  177.    endif
  178.  
  179.  
  180.    ***************************************************************************
  181.    procedure ViewEditOnClick
  182.  
  183.    * Toggle between View and Edit modes.
  184.    ****************************************************************************
  185.  
  186.    form.ViewEdit()
  187.  
  188.  
  189.    ****************************************************************************
  190.    procedure Exit_OnClick
  191.    ****************************************************************************
  192.  
  193.    form.Close()
  194.  
  195.  
  196. ENDCLASS
  197.  
  198.